package com.dzh.util;


import com.dzh.dao.BookMapper;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import com.dzh.pojo.Books;

import java.io.IOException;
import java.io.InputStream;


public class Util {

    public static void sqlDone() throws IOException {
        String file="mybatis-config.xml";
        InputStream stream = Resources.getResourceAsStream(file);
        SqlSessionFactory factory=new SqlSessionFactoryBuilder().build(stream);
        SqlSession sqlSession=factory.openSession();
       // BookMapper bookMapper= sqlSession.getMapper(BookMapper.class);
        Books book=(Books)sqlSession.selectOne("com.dzh.dao.BookMapper.queryBookById",1);
        System.out.println("书本实例"+book);
    }

    public static void main(String[] args) throws IOException{
        sqlDone();
    }


}
